<template>
  <div class="main-header">
    <div class="logo">
      <img src="@/assets/img/logo.png">
      <div class="label">微信点餐管理员</div>
    </div>
    <div class="info">
      <el-dropdown>
        <div class="shop-area" style="margin-left: 10px">
          <i class="iconfont my-icon-geren"></i>
          <div class="shop-name">{{ status.userName }}</div>
          <i class="iconfont my-icon-xiangxia" style="margin-right: 10px"></i>
        </div>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="signOut">
              退出
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup>
import {reactive} from "vue";
import VueCookies from "vue-cookies";
import {ElMessage} from "element-plus";
import router from "@/router";

const status = reactive({
  userName: localStorage.getItem("userName")
});

const signOut = () => {
  VueCookies.remove("tokenWeb");
  localStorage.removeItem("userName");
  ElMessage.success("退出成功");
  router.push({name: 'Login'});
}
</script>

<style lang="scss" scoped>
.main-header {
  width: 100%;
  height: 100%;
  background-color: rgba(249, 249, 249, 1);
  border-bottom: 1px solid #d5d5d5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .logo {
    display: flex;
    align-items: center;
    img {
      height: 40px;
      width: 40px;
    }
    .label {
      height: 26px;
      color: rgba(16, 16, 16, 1);
      font-size: 18px;
    }
  }
  .info {
    margin-right: 20px;
    display: flex;
    align-items: center;
    .shop-area{
      display: flex;
      align-items: center;
      cursor: pointer;
      .shop-name {
        margin-left: 10px;
        margin-right: 5px;
        font-size: 16px;
      }
      .mg-icon {
        margin-right: 10px;
      }
      :deep .el-badge {
        .el-badge__content {
          height: 12px;
          font-size: 12px;
          display: flex;
          align-items: center;
          justify-content: center;
          transform: translateY(-50%) translateX(60%);
        }
      }
    }
    :deep.el-popover {
      padding: 10px 0 !important;
    }
  }
}
</style>